﻿//----------------------------------------------------

#region 命名空间

//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Data;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using WinnerCMS.Common;
using WinnerCMS.Data;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// 业务逻辑类 WinnerCMS_UDT 的摘要说明。
    /// </summary>
    public class UDTManage
    {
        private static readonly UDTDal MyDAL = new UDTDal();

        #region 添加

        /// <summary>
        /// 添加
        /// </summary>
        public Result Add(UDT model)
        {
            Result res = new Result();
            if (model.Name.Length == 0)
            {
                res.Errors = "“标签名称”不能为空！";
                return res;
            }

            if (model.Id == 0)
            {
                model.CheckInTime = DateTime.Now;
                MyDAL.Add(model);
            }
            else
            {
                MyDAL.Edit(model);
            }
            return res;
        }

        #endregion

        #region 删除

        /// <summary>
        /// 删除
        /// </summary>
        public void Delete(string IDs, UpdatePanel UpdatePanel1)
        {
            if (string.IsNullOrEmpty(IDs))
            {
                MsgBox.Message("至少选择一项。", UpdatePanel1);
            }
            else
            {
                MyDAL.Delete(MyConvert.ConvertToArr(IDs));
            }
        }

        #endregion

        #region 加载数据

        /// <summary>
        /// 加载数据
        /// </summary>
        public UDT GetInfo(string ID)
        {
            return MyDAL.GetInfo(int.Parse(ID));
        }

        #endregion

        #region 绑定分页

        /// 绑定分页
        /// </summary>
        /// <param name="Sort"></param>
        /// <param name="Keyword"></param>
        /// <param name="pp"></param>
        /// <returns></returns>
        public IList<UDT> BindList(string Sort, string Keyword, PagingParam pp)
        {
            return MyDAL.BindList(Sort, Keyword, pp);
        }

        #endregion

        #region 取得智能标签

        /// <summary>
        /// 取得智能标签
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public UDT GetTag(string Name)
        {
            return MyDAL.GetTag(Name);
        }

        /// <summary>
        /// 取得智能标签
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IList<UDT> GetTag(int Type)
        {
            return MyDAL.GetTag(Type);
        }

        #endregion

        #region 停用或者启用

        /// <summary>
        /// 停用或者启用
        /// </summary>
        /// <param name="IDs"></param>
        /// <returns></returns>
        public Result StopitOrRunit(string IDs)
        {
            Result res = new Result();
            try
            {
                MyDAL.StopOrRunit(IDs);
            }
            catch (Exception ex)
            {
                res.Errors = ex.Message;
            }
            return res;
        }

        #endregion
    }
}